<?php

/**
 * LoginForm class.
 * LoginForm is the data structure for keeping
 * user login form data. It is used by the 'login' action of 'SiteController'.
 */
class LoginForm extends CFormModel
{
	const ERR_CODE_ACCOUNT_LOOKED = 0;
    const ERR_CODE_EMAIL_NOT_EXIST = 1;
    const ERR_CODE_FIRST_LOGIN = 2;
    const ERR_CODE_LAST_LOGIN = 3;

	public $username;
	public $password;
	public $captcha;

	public $_identity;

	/**
	 * Declares the validation rules.
	 * The rules state that username and password are required,
	 * and password needs to be authenticated.
	 */
	public function rules()
	{
		return array(
			// username and password are required
			array('username, password', 'required'),
			array('username','email'),
			array('captcha', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
		);
	}

	/**
	 * Declares attribute labels.
	 */
	public function attributeLabels()
	{
		return array(
			'username'=>'Email tài khoản',
			'password'=>'Mật khẩu đăng nhập',
			'captcha'=>'Mã an toàn',
		);
	}
}
